import pcbnew
import os
import subprocess
import sys
import wx
  
class FreeroutingRun(pcbnew.ActionPlugin):
    def defaults(self):
        self.name = "FreeroutingRun 1.0"
        self.category = "Artistic PCBs"
        self.description = "Freerouting Launcher "
        self.show_toolbar_button = True # Optional, defaults to False
        self.icon_file_name = os.path.join(os.path.dirname(__file__), 'FL.png') # Optional, defaults to ""

    def Run(self):
        # The entry function of the plugin that is executed on user action
        board = pcbnew.GetBoard()
        basename = os.path.splitext(board.GetFileName())
        os.system('java -jar -Xmx16g "'+os.path.dirname(os.path.abspath(__file__))+'"/jar/FreeRouting.jar -mp 100 -de '+basename[0]+'.dsn"')
		

FreeroutingRun().register() # Instantiate and register to Pcbnew
